package frobagroup.services.backstage.impl;

import frobagroup.entities.backstage.Staff;
import frobagroup.entities.backstage.StaffProfile;
import frobagroup.repositories.backstage.StaffProfileRepository;
import frobagroup.repositories.backstage.StaffRepository;
import frobagroup.services.StaffLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by Tinsley on 2018/5/11.
 */
@Service
public class StaffLoginServiceImpl implements StaffLoginService {

    @Autowired
    private StaffRepository staffRepository;
    @Autowired
    private StaffProfileRepository staffProfileRepository;

    @Override
    public Staff findByEmailOrUsername(String email, String username) {
        return staffRepository.findByEmailOrUsername(email,username);
    }

    @Override
    public void lastLoginTime(Staff Staff) {
        Staff.setLastLoginTime(new Date());
        staffRepository.save(Staff);
    }

    @Override
    public StaffProfile findBySId(String sId) {
        return staffProfileRepository.findBySId(sId);
    }
}
